<cfif IsDefined("form.email")>
	<cfquery name="getuname" datasource="exp" >
	
		SELECT *
		FROM user
		WHERE email=<cfqueryparam cfsqltype="cf_sql_varchar" value="#email#">
		
	</cfquery>

	<cfif getuname.RecordCount gt 0>
		<cfmail type="html" 
		from="0907317c@student.gla.ac.uk" 
		subject="Forgotten Username" 
		to="#getuname.email#"
		server= "mr1.dcs.gla.ac.uk"
		spoolenable="no">
		Your Ecada username is:<br>
		#getuname.username#<br>
		</cfmail>
		<cfset session.message="Your username has been sent to your email!">
		<cflocation url="/ecada/index.cfm">
		<cfabort>
	<cfelse >
		<cfset session.message="Unknown e-mail address!">
		<cflocation url="/ecada/index.cfm">
		<cfabort>
	</cfif>
<cfelse>
	<cfset session.message="E-mail was not defined!">
	<cflocation url="/ecada/index.cfm">
	<cfabort>
</cfif>
